<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="zh-cn">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<meta name="decorator" content="datePicker"/>
		<title>后台管理</title>

		<%String status=(String)request.getAttribute("status"); %>
		<script type="text/javascript">
			$(function(){
				$("#order").addClass("active");
				var i=0;
				if("<%=status%>"=="待付款"){
					i=2;
				}else if("<%=status%>"=="已付款"){
					i=3;
				}else if("<%=status%>"=="已发货"){
					i=4;
				}else if("<%=status%>"=="已完成"){
					i=5;
				}
				$("#order").find("ul li").eq(i).addClass("active");
			})
		</script>
	</head>

	<body>

		<div class="admin">
			<div class="panel">
				<div class="panel-head">
					<form method="post" action="order!search1.action">
						<div class="line-middle">
							<div class="x3">

							</div>
							<div class="x5 ">
								<input name="key0" type="text" class="input radius-rounded"
									placeholder="请输入订单编号" />
							</div>
							<div class="x4">
								<button type="submit" class="button bg-blue">
									搜索
								</button>
							</div>
						</div>
					</form>

				</div>
				<div class="padding border-bottom">

					<div style="text-align: center">
						<form method="post" action="order!findbytime.action"
							class="form-inline">
							<div class="form-group">
								<div class="label">
									<label>
										开始时间:
									</label>
								</div>
								&nbsp;
								<div class="field">
									<input name="time1" id="startTime" type="text"
										class="input input-auto" size="35"
										onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'#F{$dp.$D(\'endTime\')}'})"
										placeholder="请输入开始时间" />
								</div>
							</div>
							&nbsp;&nbsp;
							<div class="form-group">
								<div class="label">
									<label >
										结束时间:
									</label>
								</div>
								&nbsp;
								<div class="field">
									<input name="time2" id="endTime" type="text" class="input"
										size="35"
										onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'startTime\')}',maxDate:'%y-%M-%d %H:%m:%s'})"
										placeholder="请输入结束时间" />
								</div>
							</div>
							<button class="button bg-sub button-small" name="cx"
								onclick="return getResult()">
								查看
							</button>

						</form>

					</div>
				</div>


				<div class="panel-body">
					<div class="panel admin-panel">
						<div class="panel-head">
							全部订单
						</div>
						<script type="text/javascript">
							function formsub(){
								$('#form').attr('action',action);
								submit();
							}
						</script>
						<form id="form" method="post" action="">
							<div class="padding border-bottom">
								<input type="button" id="selectall"
									class="button button-small checkall" checkfor="id" value="全选" />
								<input style="width:6%;" onclick="formsub('<%=path %>/admin/order/order!deletebyid.action');"
									class="button button-small border-yellow" value="批量删除" />
								<input style="width:6%;" onclick="formsub('<%=path %>/admin/order/order!export.action');"
									class="button button-small border-yellow" value="导出订单" />
							</div>

							<table class="table table-hover">
								<tr>
									<th width="100">
										选择
									</th>
									<th width="250">
										下单时间
									</th>
									<th width="150">
										状态
									</th>
									<th width="150">
										付款方式
									</th>
									<th width="150">
										购买人
									</th>
									<th width="150">
										订单金额
									</th>
									<th width="200">
										操作
									</th>
								</tr>

								<s:iterator value="orders" var="o">

									<tr>
										<td>
											<input type="checkbox" class="choose" name="id"
												value="<s:property value="id"/>" />
										</td>

										<td>
											<s:property value="time1" />
										</td>
											<td>
											<s:if test="#o.status=='待付款'">
												<s:property value="status" />
											</s:if>
											<s:else>
											   <span style="color:red;">
											   <s:property value="status" />
											   </span>
											</s:else>
											</td>
											<td>
												<s:property value="paymethod" />
											</td>
										<td>
											<s:property value="name" />
										</td>
										<td>
											<s:if test="paymethod=='微信支付'">
												<s:property value="allprice" />
											</s:if>
											<s:else>
												<s:property value="allscore" />
											</s:else>
										</td>
										<td>
											<a class="button border-blue button-little"
												href="order!findbyid.action?order1.id=<s:property value="id"/>">查看</a>&nbsp;

											<s:if test="#o.status=='待付款'">
												<a class="button border-yellow button-little"
													href="order!deleteone.action?order.id=<s:property value="id"/>&page=${page}"
													onclick="{if (confirm('确认删除?')) {return true;}return false;};">删除</a>
											</s:if>

											<s:if test="#o.status=='已付款'">
													<a class="button border-green button-little"
														href="order!qufahuo.action?order.id=<s:property value="id"/>">发货</a>
											</s:if>
											<s:if test="#o.status=='已发货'">
												<a class="button border-green button-little"
													href="order!wc.action?order.id=<s:property value="id"/>">完成</a>
											</s:if>
											<s:if test="#o.status=='已完成'">
												<a class="button border-red button-little">已完成</a>
											</s:if>
										</td>
									</tr>
								</s:iterator>
							</table>
						</form>
						<form id="formform" action="order!beizhu.action">
							<input type="hidden" name="keykey" value="${keykey }"/>
							<input id="orderid" type="hidden" name="order.id" value=""/>
							<input id="bzbz" type="hidden" name="order.adminBz" value=""/>
							<input type="hidden" name="page" value="${page }"/>
						</form>
						<script type="text/javascript">
							function sureBz(obj){
								var beizhu = $(obj).parent().find('input').val();
								//alert("beizhu："+beizhu);
								if(beizhu==""){
									alert("请输入备注！");
								}else{
									$('#bzbz').val(beizhu);
									$('#formform').submit();
									$(obj).parent().find('input').val('');
								}
							}
							function beizhu(orderid,obj){
								//order!beizhu.com.kecheng.action?order.id=<s:property value="id"/>
								$(obj).hide();
								$(obj).next().show();
								//$('#beizhu').hide();
								//$('#addBz').show();
								$('#orderid').val(orderid);
							}
						
						</script>
						<br />

						<div>
							<s:include value="/admin/commons/page.jsp"></s:include>
						</div>

					</div>
				</div>

			</div>
		</div>

		<script type="text/javascript">
			function submit() {
				var length = $("input[type='checkbox']:checked").length;
				//alert(length);
				if(length>0){
					document.getElementById("form").submit();
				}else{
					alert("请选择订单");
				}
			}
		</script>

	</body>
</html>